package com.breeze.theme

import android.content.Context
import android.content.res.Configuration
import androidx.appcompat.app.AppCompatDelegate


object UiModelUtil {
    lateinit var context: Context
    fun init(context: Context) {
        this.context = context
    }

    fun isNightMode(): Boolean {
        val uiMode: Int =
            context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
        return uiMode == Configuration.UI_MODE_NIGHT_YES
    }

    fun switchNightMode(night: Boolean) {
        val nightMode =
            if (night) AppCompatDelegate.MODE_NIGHT_YES else AppCompatDelegate.MODE_NIGHT_NO
        AppCompatDelegate.setDefaultNightMode(nightMode)
    }
}